package top.luo.mycat.server;

/**
 * @author luo
 * @date 2021-03-19 11:57
 */
public abstract class HttpServlet implements Servlet {

    public static final String GET_METHOD = "GET";

    public static final String POST_METHOD = "POST";

    public abstract void doGet(Request request, Response response);

    public abstract void doPost(Request request, Response response);

    @Override
    public void service(Request request, Response response) {
        if (GET_METHOD.equals(request.getMethod())) {
            doGet(request, response);
        } else if (POST_METHOD.equals(request.getMethod())) {
            doPost(request, response);
        } else {
            throw new RuntimeException("请求方法不支持！");
        }
    }

}
